home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 36 / dv_guard.zip / DV-GUARD.ASM next >
Assembly Source File  |  1990-03-11  |  8KB  |  335 lines

  1.  page ,132
  2.  .model tiny
  3.  .code
  4. first:
  5. ;
  6. ; DV-GUARD is an enhanced version of the marvelously written original
  7. ;    WATCHCAT program created by Joseph R. Ahlgren.
  8. ;    With his permission, it has been revised to allow use in
  9. ;    the DESQview environment.  In addition, due to popular request,
  10. ;    the original "20 ring reboot" feature has been modified to
  11. ;    reboot the system on 8 rings.
  12. ;
  13. ; Many people have contributed to this revised program.  Quarterdeck
  14. ;    Office Systems (the developers of DESQview), were certainly 
  15. ;    instrumental in making this version a success.  In addition, the
  16. ;    dedication of programmer Anthony Petillo was an absolute
  17. ;    necessity to making this whole thing come about.
  18. ;
  19. ; For more information, please see DV-GUARD.DOC 
  20. ;   
  21. ;
  22. ; DV-GUARD performs 5 critical functions for any RBBS system
  23. ;          running under DESQview:
  24. ;
  25. ;  1.  Reboots the system if no carrier is detected in 8 hours.
  26. ;      This catches RBBS or system failures.
  27. ;
  28. ;  2.  Reboots the system if carrier is lost during critical period.
  29. ;      This allows Doors to be used safely.
  30. ;
  31. ;  3.  Reboots the system if 8 rings without answering phone.
  32. ;      This allows system to be restarted by phone.
  33. ;
  34. ;  4.  Reboots system if "Hit any key to return to system" message appears.
  35. ;      This restarts system on an RBBS glitch.
  36. ;
  37. ;  5.  Drops carrier if L&R shift keys pressed simultaneously.
  38. ;      This allows users to be logged off without a nasty message.
  39. ;
  40. ;
  41. ; DV-GUARD loads the TSR and disables all functions
  42. ; DV-GUARD OFF disables all functions
  43. ; DV-GUARD ON enables 1,3,4,and 5
  44. ; DV-GUARD TIMER enables 2,4,and 5
  45. ;
  46. ;ComPort = 03f8h  ;{COM1}
  47. ;ComPort = 02f8h  ;{COM2}
  48. ;ComPort = 03e8h  ;{COM3}
  49. ;ComPort = 02e8h  ;{COM4}
  50. ;ScreenSegment = 0b800h  ;{Color}
  51. ;ScreenSegment = 0b000h  ;{Mono}
  52. ;
  53. ModemStatus = 0006h
  54. ModemControl = 0004h
  55. CarrierDetect = 0080h
  56. RingIndicator = 0040h
  57. tpm = 1092 ; {ticks per minute}
  58. RingTicks = 110; {6 seconds}
  59.  org 100h
  60. start:
  61.  jmp init
  62. RingTrigger dw 0
  63. RingTimer db 0
  64. Flag db 'F' and 0fh  ;  OFF ON TIME = F O I
  65. TimerInt dd ?
  66. Minutes dw 8*60  ;{minutes of no carrier to trigger reset}
  67. Seconds dw tpm
  68. MinReset dw 8*60
  69. WarmBoot dd 0f000fff0h
  70. ExitTimer db 0
  71. DropTrigger db 3  ;Drop DTR on L&R shift
  72. ExitMessage db 'Hit any key to return to system'
  73. ExitMessageEnd db 0
  74. ComPort dw 02f8h  ;{COM2}
  75. ScreenSegment dw 0b000h  ;{Mono}
  76. Ident db "jOeY"
  77. Ident2 db "50c4"
  78. timer:
  79.  assume ds:nothing,es:nothing,ss:nothing
  80.  cmp cs:[Flag],'F' and 0fh
  81.  jne SystemOn
  82.  jmp cs:[TimerInt]
  83. SystemOn:
  84.  push ax
  85.  push dx
  86.  push ds
  87. ;
  88. ;
  89. ;  4.  Reboots the system if "Hit any key to return to system" message appears.
  90. ;      This restarts the system on an RBBS glitch.
  91. ;
  92.  dec cs:[ExitTimer]
  93.  jnz NoExitLoop
  94.  push cx
  95.  push si
  96.  push di
  97.  mov ax,cs:[ScreenSegment]
  98.  mov ds,ax
  99.  mov cx,25
  100.  xor si,si
  101. SSLoop1:
  102.  push cx
  103.  push si
  104.  mov cx,ExitMessageEnd-ExitMessage
  105.  mov di,offset ExitMessage
  106. SSLoop2:
  107.  lodsw
  108.  cmp al,cs:[di]
  109.  jne SSLoop2x
  110.  inc di
  111.  loop SSLoop2
  112.  jmp short NoCarrier
  113. SSLoop2x:
  114.  pop si
  115.  pop cx
  116.  add si,160
  117.  loop SSLoop1
  118.  pop di
  119.  pop si
  120.  pop cx
  121. NoExitLoop:
  122. ;
  123. ;
  124. ;  5.  Drops carrier if L&R shift keys pressed simultaneously.
  125. ;      This allows users to be logged off without a nasty message.
  126. ;
  127.  xor ax,ax
  128.  mov ds,ax
  129.  assume ds:Lowmem
  130.  mov al,[ShiftStatus]
  131.  and al,0fh
  132.  cmp al,cs:[DropTrigger]
  133.  jne NoShift
  134.  mov dx,cs:[ComPort]
  135.  add dx,ModemControl
  136.  in al,dx
  137.  and al,0feh
  138.  out dx,al       ;drop DTR
  139. NoShift:
  140. ;
  141. ;
  142. ;  3.  Reboots the system if 8 rings without answering phone.
  143. ;      This allows system to be restarted by phone.
  144. ;
  145.  mov dx,[ComPort]
  146.  add dx,ModemStatus
  147.  in al,dx
  148.  test al,RingIndicator
  149.  jz NotRinging
  150.  or cs:[RingTrigger],1
  151. NotRinging:
  152.  dec cs:[RingTimer]
  153.  jnz NoRingTime
  154.  mov cs:[RingTimer],RingTicks
  155.  mov ax,cs:[RingTrigger]
  156.  cmp ax,0ffffh
  157.  je NoCarrier
  158.  shl ax,1
  159.  mov cs:[RingTrigger],ax
  160. ;
  161. ;
  162. ;  2.  Reboots the system if carrier lost during critical period.
  163. ;      This allows Doors to be used safely.
  164. ;
  165. NoRingTime:
  166.  cmp cs:[Flag],'I' and 0fh
  167.  jb NoMonitor
  168.  je TimeCheck
  169.  in al,dx
  170.  and al,CarrierDetect
  171.  jz NoCarrier
  172. NoMonitor:
  173.  pop ds
  174.  pop dx
  175.  pop ax
  176.  jmp cs:[TimerInt]
  177. NoCarrier:
  178.   cli                           ; disable interrupts
  179.   mov ax,0                      ; clear ax
  180.   mov ds,ax                     ; clear data seg reg
  181.   mov bx,0472h                  ; store 1234 at address 472
  182.   mov word ptr [bx],01234h
  183.   mov ss,ax                     ; clear stack seg reg
  184.   mov sp,0400h                  ; set stack ptr to 400
  185.   jmp cs:[warmboot]             ; goto to warmboot area
  186. ;
  187. ;
  188. ;  1.  Reboots the system if no carrier in specified period of time.
  189. ;      This catches RBBS or system failures.
  190. ;
  191. TimeCheck:
  192.  test al,CarrierDetect
  193.  jnz ResetTime
  194.  dec cs:[Seconds]
  195.  jnz NoMonitor
  196.  mov cs:[Seconds],tpm
  197.  dec cs:[Minutes]
  198.  jz NoCarrier
  199.  jmp short NoMonitor
  200. ResetTime:
  201.  mov ax,cs:[MinReset]
  202.  mov cs:[Minutes],ax
  203.  jmp short NoMonitor
  204. ;
  205. ;
  206. ;
  207. ;
  208.  assume ds:@code,es:@code,ss:@code
  209. init:
  210.  mov dx,offset SignOnMessage
  211.  mov ax,0900h
  212.  int 21h     ;print load message
  213.  mov ax,[word ptr Ident2]
  214.  xor [word ptr Ident],ax
  215.  mov ax,[word ptr Ident2+2]
  216.  xor [word ptr Ident+2],ax
  217.  xor dx,dx
  218.  mov es,dx
  219.  mov si,offset Ident
  220.  mov cx,cs
  221.  mov ax,[si]
  222. findloop:
  223.  cmp ax,es:[si]
  224.  jz found
  225. NotQuite:
  226.  inc dx
  227.  mov es,dx
  228.  loop findloop
  229. LoadDVGUARD:
  230.  xor bx,bx
  231.  mov es,bx
  232.  mov bl,ds:[82h]
  233.  cmp bl,'0'
  234.  jle NoCom
  235.  cmp bl,'4'
  236.  jle ComSpec
  237. NoCom:
  238.  mov bl,'1'
  239. ComSpec:
  240.  mov [ComPortNumber],bl
  241.  add bx,bx
  242.  mov ax,es:[bx+400h-31h-31h]
  243.  mov [ComPort],ax
  244.  cmp byte ptr ds:[83h],'C'
  245.  jnz NotColor
  246.  mov [ScreenSegment],0b800h
  247.  mov [ScreenSegNum],'8'
  248. NotColor:
  249.  mov ax,3508h
  250.  int 21h     ;get timer interrupt
  251.  mov [word ptr TimerInt],bx
  252.  mov [word ptr TimerInt+2],es
  253.  mov dx,offset Timer
  254.  mov ax,2508h
  255.  int 21h     ;set timer interrupt
  256.  mov dx,offset message1
  257.  mov ax,0900h
  258.  int 21h     ;print load message
  259.  mov dx,(init-first+15)/16
  260.  mov ax,3101h
  261.  int 21h      ;TSR
  262. Found:
  263.  mov bx,[si+2]
  264.  cmp bx,es:[si+2]
  265.  jnz NotQuite
  266.  mov ax,es
  267.  mov bx,10h
  268.  mov di,offset message2x
  269.  mov cx,4
  270. loc:
  271.  mul bx
  272.  cmp dl,9
  273.  jbe locx
  274.  add dl,7
  275. locx:
  276.  add dl,'0'
  277.  mov [di],dl
  278.  inc di
  279.  loop loc
  280.  mov ax,es:[MinReset]
  281.  mov es:[Minutes],ax
  282.  mov al,ds:[83h]
  283.  and al,0fh
  284.  mov es:[Flag],al
  285.  mov dx,offset message2tim
  286.  cmp al,'I' and 0fh
  287.  jz done
  288.  mov dx,offset message2off
  289.  jb done
  290.  mov dx,offset message2on
  291. done:
  292.  push dx
  293.  mov dx,offset message2
  294.  mov ax,0900h
  295.  int 21h
  296.  pop dx
  297.  mov ax,0900h
  298.  int 21h
  299.  mov ax,4c00h
  300.  int 21h
  301. message1 db 0ah,0dh,'DV-GUARD Loaded, set to COM'
  302. ComPortNumber db '1 and Screen B'
  303. ScreenSegNum db '000',0ah,0dh,'$'
  304. message2 db 0ah,0dh,'DV-GUARD found at '
  305. message2x db '0000 and set to $'
  306. message2on db 'ON',0ah,0dh,'$'
  307. message2off db 'OFF',0ah,0dh,'$'
  308. message2tim db 'TIMER',0ah,0dh,'$'
  309. SignOnMessage db 0dh,0ah,'DV-GUARD: RBBS protection when running under DESQview'
  310.  db '   ',0dh,0ah
  311.  db ' DV-GUARD may be freely distributed and/or modified.  Enjoy!',0dh,0ah
  312.  db '   ',0dh,0ah
  313.  db ' Load with DV-GUARD ps, where p is the port number (1,2,3,4)',0dh,0ah
  314.  db '  and s is the screen type (Color or Mono), e.g., DV-GUARD 2C',0dh,0ah
  315.  db '  specifies COM2 and Color Screen',0ah,0dh
  316.  db '   ',0dh,0ah
  317.  db ' Subsequent calls are DV-GUARD ON, DV-GUARD OFF, and DV-GUARD TIMER',0dh,0ah
  318.  db '  OFF disables all functions',0dh,0ah
  319.  db '  ON reboots if carrier lost',0dh,0ah
  320.  db '  TIMER reboots if 8 rings without answering phone, if no carrier',0dh,0ah
  321.  db '   in 8 hours, or if "Hit any key to return to system" appears on screen',0dh,0ah
  322.  db '   Also, pressing both Left and Right Shift keys simultaneously will',0dh,0ah
  323.  db '   drop the line, logging off the current user.',0dh,0ah
  324.  db '$'
  325.  ends
  326. Lowmem segment at 0000h
  327.  org 417h
  328. ShiftStatus db ?
  329. Lowmem ends
  330.  end start
  331.  
  332.  
  333.  
  334.